<?php
$script_tmp = explode('/', $_SERVER['SCRIPT_NAME']);
$sctiptName = array_pop($script_tmp);
include_once("../includes/global.php");
@session_start();
$config['language'] = isset($_SESSION["ADMIN_LANG"])?$_SESSION["ADMIN_LANG"]:$config['language'];
include_once("../lang/" . $config['language'] . "/admin.php");
include_once("../module/product/includes/plugin_order_class.php");
$order = new order;
include_once("../module/product/includes/plugin_delay_order_class.php");

include_once("../module/micro_stock/includes/plugin_micro_stock_class.php");
$microStock = new MicroStock();

include_once("../module/huopin/includes/plugin_huopin_class.php");
$huopin = new Huopin();
//===========================================
if(empty($_SESSION["ADMIN_USER"])||empty($_SESSION["ADMIN_PASSWORD"]))
	msg('index.php');

$general_shop =$order->get_general_shop();
$stock_shops=$order->get_stock_shops();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="main.css" rel="stylesheet" type="text/css" />
<title><?php echo lang_show('business_manager_system');?></title>
</head>
<body>
<div class="bigbox">
	<div class="bigboxhead"><?php echo lang_show('manager_home');?></div>
	<div class="bigboxbody">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    	  <tr class="theader">
		    <td colspan="4" align="left">今日一览</td>
      	  </tr>
      	  <tr>
      	  	<td><strong>今日新增会员</strong></td>
            <td>
			<a href="module.php?m=member&s=member.php&onlytoday=1&only=2&ordrby=regtime&category=user&Submit=搜索">
			<?php $sql="select count(*) as num from ".MEMBER." where status!=-4 AND regtime>='".date('Y-m-d 00:00:00',time())."'";$db->query($sql);echo $db->fetchField('num');?>
			</a>
			</td>
			<td><strong>延期未发货订单</strong></td>
            <td>
            
            <?php foreach ($stock_shops as $item){if($general_shop&&$general_shop!=$item['id']){continue;}echo " &nbsp; ".$item['title'];?> : 
			<a href="module.php?m=product&s=order_delay_list.php&stock_shop=<?php echo $item['id']; ?>">
			<?php $_GET['stock_shop']= $item['id'];$delayOrder = new delayOrder;echo  $delayOrder->getTotalNum();?>
			</a> 
			<?php }?>
			<?php if (!$general_shop){?>
				 &nbsp; 全部 : <a href="module.php?m=product&s=order_delay_list.php">
				<?php unset($_GET['stock_shop']);$delayOrder = new delayOrder;echo  $delayOrder->getTotalNum();?>
			</a>
			<?php }?>
			</td>
      	  </tr>
      	  <tr>
			<td><strong>今日销量</strong></td>
            <td> 
            <?php $sql="select count(*) as num,stock_shop from ".ORDER." where status>='2' and order_time>='".strtotime(date('Y-m-d 00:00:00',time()))."' group by stock_shop";$db->query($sql);$nums=(array)$db->getRows();foreach ($nums as $item){$stock_nums[$item['stock_shop']]=$item['num'];}?>
			<?php foreach ($stock_shops as $item){if($general_shop&&$general_shop!=$item['id']){continue;}echo " &nbsp; ".$item['title'];?> : 
			<a href="module.php?m=product&s=order.php&onlytoday=1&stock_shop=<?php echo $item['id']; ?>">
			<?php echo $order->getOrderNum($item['id'],1);?>
			</a> 
			<?php }?>
			<?php if (!$general_shop){
			    $orderNum = $order->getOrderNum(0,1,1) + $order->getOrderNum(0,1,2);//普通订单和分销订单
			    $microShopNum = $order->getOrderNum(0,1,3);//微店订单
			    $microStockNum = $microStock->getOrderNum(0,1);//微仓订单
			    $huopinNum = $huopin->getOrderNum(0,1);//伙拼订单
			    $todayAllNum = $orderNum + $microShopNum + $microStockNum + $huopinNum;
		    ?>
				 &nbsp;&nbsp;&nbsp; 普通 : <a href="module.php?m=product&s=order.php&onlytoday=1">
				<?php echo $orderNum;?>
			</a>
				&nbsp; 微仓 : <a href="module.php?m=micro_stock&s=micro_stock_orders.php&onlytoday=1">
				<?php echo $microStockNum;?>
			</a>
				&nbsp; 伙拼 : <a href="module.php?m=huopin&s=order.php&onlytoday=1">
				<?php echo $huopinNum;?>
			</a>
				&nbsp; 微店 : <a href="module.php?m=product&s=order.php&onlytoday=1&order_type=3">
				<?php echo $microShopNum;?>
			</a>
				&nbsp; 全部: <?php echo $todayAllNum;?>
			<?php }?>
			</td>
			<td><strong>今日销售额</strong></td>
			<td>
			<?php foreach ($stock_shops as $item){if($general_shop&&$general_shop!=$item['id']){continue;}echo " &nbsp; ".$item['title'];?> : 
			<?php echo  $order->getSalesInfo($item['id'],1);?>
			<?php }?>
			<?php if (!$general_shop){
			    $orderAmount = $order->getSalesInfo(0,1,1) + $order->getSalesInfo(0,1,2);
			    $microShopAmount = $order->getSalesInfo(0,1,3);
			    $microStockAmount = $microStock->getSalesInfo('',1);
			    $huopinAmount = $huopin->getSalesInfo('',1);
			    $todayAllAmount = $orderAmount + $microShopAmount + $microStockAmount + $huopinAmount;
			    //普通订单优惠券总额
			    $orderCpnsPrice = $order->getCpnsPrice(1,1) + $order->getCpnsPrice(1,2);
			    //微店订单优惠券总额
			    $microShopCpnsPrice = $order->getCpnsPrice(1,3);
		    ?>
				 &nbsp;&nbsp;&nbsp; 普通 : 
				<?php echo $orderAmount;?>
				&nbsp; 微仓 : 
				<?php echo $microStockAmount;?>
				&nbsp; 伙拼 : 
				<?php echo $huopinAmount;?>
				&nbsp; 微店 : 
				<?php echo $microShopAmount;?>
				&nbsp; 全部: 
				<?php echo $todayAllAmount;?>
				&nbsp; 普通订单优惠券: 
				<?php echo $orderCpnsPrice;?>
				&nbsp; 微店订单优惠券: 
				<?php echo $microShopCpnsPrice;?>
			<?php }?>
			</td>
      	  </tr>
      	  <tr>
    			<td><strong>昨日销量</strong></td>
                <td> 
                <?php $sql="select count(*) as num,stock_shop from ".ORDER." where status>='2' and order_time>='".strtotime(date('Y-m-d 00:00:00',time()))."' group by stock_shop";$db->query($sql);$nums=(array)$db->getRows();foreach ($nums as $item){$stock_nums[$item['stock_shop']]=$item['num'];}?>
    			<?php foreach ($stock_shops as $item){if($general_shop&&$general_shop!=$item['id']){continue;}echo " &nbsp; ".$item['title'];?> : 
    			<a href="module.php?m=product&s=order.php&onlytoday=2&stock_shop=<?php echo $item['id']; ?>">
    			<?php echo $order->getOrderNum($item['id'],2);?>
    			</a> 
    			<?php }?>
    			<?php if (!$general_shop){
    			    $orderNum = $order->getOrderNum(0,2,1) + $order->getOrderNum(0,2,2);
    			    $microShopNum = $order->getOrderNum(0,2,3);
    			    $microStockNum = $microStock->getOrderNum(0,2);
    			    $huopinNum = $huopin->getOrderNum(0,2);
    			    $todayAllNum = $orderNum + $microShopNum + $microStockNum + $huopinNum;
			    ?>
    				 &nbsp;&nbsp;&nbsp; 普通 : <a href="module.php?m=product&s=order.php&onlytoday=2">
    				<?php echo $orderNum;?>
    			</a>
    				 &nbsp; 微仓 : <a href="module.php?m=micro_stock&s=micro_stock_orders.php&onlytoday=2">
    				<?php echo $microStockNum;?>
    			</a>
    					&nbsp; 伙拼 : <a href="module.php?m=huopin&s=order.php&onlytoday=2">
    				<?php echo $huopinNum;?>
    			</a>
					&nbsp; 微店 : <a href="module.php?m=product&s=order.php&onlytoday=2&order_type=3">
    				<?php echo $microShopNum;?>
    			</a>
					&nbsp; 全部: <?php echo $todayAllNum;?>
    			<?php }?>
    			</td>      	  
      	  		<td><strong>昨日销售额</strong></td>
    			<td>
    			<?php foreach ($stock_shops as $item){if($general_shop&&$general_shop!=$item['id']){continue;}echo " &nbsp; ".$item['title'];?> : 
    			<?php echo  $order->getSalesInfo($item['id'],2);?>
    			<?php }?>
    			<?php if (!$general_shop){
    			    $orderAmount = $order->getSalesInfo(0,2,1) + $order->getSalesInfo(0,2,2);
    			    $microShopAmount = $order->getSalesInfo(0,2,3);
    			    $microStockAmount = $microStock->getSalesInfo('',2);
    			    $huopinAmount = $huopin->getSalesInfo('',2);
    			    $todayAllAmount = $orderAmount + $microShopAmount + $microStockAmount + $huopinAmount;
    			    //普通订单优惠券总额
    			    $orderCpnsPrice = $order->getCpnsPrice(2,1) + $order->getCpnsPrice(2,2);
    			    //微店订单优惠券总额
    			    $microShopCpnsPrice = $order->getCpnsPrice(2,3);
			    ?>
    				 &nbsp;&nbsp;&nbsp; 普通 : 
    				<?php echo $orderAmount;?>
    				&nbsp; 微仓 : 
    				<?php echo $microStockAmount;?>
    				&nbsp; 伙拼 : 
    				<?php echo $huopinAmount;?>
    				&nbsp; 微店 : 
    				<?php echo $microShopAmount;?>
    				&nbsp; 全部: 
    				<?php echo $todayAllAmount;?>
    				&nbsp; 普通订单优惠券: 
    				<?php echo $orderCpnsPrice;?>
    				&nbsp; 微店订单优惠券: 
    				<?php echo $microShopCpnsPrice;?>
    			<?php }?>
    			</td>
      	  </tr>
      	  <tr>
      	  		<td><strong>本月销量</strong></td>
                <td> 
                <?php $sql="select count(*) as num,stock_shop from ".ORDER." where status>='2' and order_time>='".strtotime(date('Y-m-d 00:00:00',time()))."' group by stock_shop";$db->query($sql);$nums=(array)$db->getRows();foreach ($nums as $item){$stock_nums[$item['stock_shop']]=$item['num'];}?>
    			<?php foreach ($stock_shops as $item){if($general_shop&&$general_shop!=$item['id']){continue;}echo " &nbsp; ".$item['title'];?> : 
    			<a href="module.php?m=product&s=order.php&onlytoday=3&stock_shop=<?php echo $item['id']; ?>">
    			<?php echo $order->getOrderNum($item['id'],3);?>
    			</a> 
    			<?php }?>
    			<?php if (!$general_shop){
    			    $orderNum = $order->getOrderNum(0,3,1) + $order->getOrderNum(0,3,2);
    			    $microShopNum = $order->getOrderNum(0,3,3);
    			    $microStockNum = $microStock->getOrderNum(0,3);
    			    $huopinNum = $huopin->getOrderNum(0,3);
    			    $todayAllNum = $orderNum + $microShopNum + $microStockNum + $huopinNum;
			    ?>
    				 &nbsp;&nbsp;&nbsp; 普通 : <a href="module.php?m=product&s=order.php&onlytoday=3">
    				<?php echo $orderNum;?>
    			</a>
    				&nbsp; 微仓 : <a href="module.php?m=micro_stock&s=micro_stock_orders.php&onlytoday=3">
				<?php echo $microStockNum;?>
			</a>
					&nbsp; 伙拼 : <a href="module.php?m=huopin&s=order.php&onlytoday=3">
				<?php echo $huopinNum;?>
			</a>
					&nbsp; 微店 : <a href="module.php?m=product&s=order.php&onlytoday=3&order_type=3">
    				<?php echo $microShopNum;?>
    			</a>
					&nbsp; 全部: <?php echo $todayAllNum;?>
    			<?php }?>
    			</td>
    			<td><strong>本月销售额</strong></td>
    			<td>
    			<?php foreach ($stock_shops as $item){if($general_shop&&$general_shop!=$item['id']){continue;}echo " &nbsp; ".$item['title'];?> : 
    			<?php echo  $order->getSalesInfo($item['id'],3);?>
    			<?php }?>
    			<?php if (!$general_shop){
    			    $orderAmount = $order->getSalesInfo(0,3,1) + $order->getSalesInfo(0,3,2);
    			    $microShopAmount = $order->getSalesInfo(0,3,3);
    			    $microStockAmount = $microStock->getSalesInfo('',3);
    			    $huopinAmount = $huopin->getSalesInfo('',3);
    			    $todayAllAmount = $orderAmount + $microShopAmount + $microStockAmount + $huopinAmount;
    			    //普通订单优惠券总额
    			    $orderCpnsPrice = $order->getCpnsPrice(3,1) + $order->getCpnsPrice(3,2);
    			    //微店订单优惠券总额
    			    $microShopCpnsPrice = $order->getCpnsPrice(3,3);
			    ?>
    				 &nbsp;&nbsp;&nbsp; 普通 : 
    				<?php echo $orderAmount;?>
    				&nbsp; 微仓 : 
    				<?php echo $microStockAmount;?>
    				&nbsp; 伙拼 : 
    				<?php echo $huopinAmount;?>
    				&nbsp; 微店 : 
    				<?php echo $microShopAmount;?>
    				&nbsp; 全部: 
    				<?php echo $todayAllAmount;?>
    				&nbsp; 普通订单优惠券: 
    				<?php echo $orderCpnsPrice;?>
    				&nbsp; 微店订单优惠券: 
    				<?php echo $microShopCpnsPrice;?>
    			<?php }?>
    			</td>      	  		
      	  </tr>
<!-- 		  <tr class="theader"> -->
<!-- 		    <td colspan="4" align="left">待处理信息</td> -->
<!--       	  </tr> -->
<!-- 	     <tr> -->
<!--             <td align="left"><strong>待审核会员</strong></td> -->
<!--             <td> -->
<!-- 			<a href="module.php?m=member&s=member.php&only=1&ordrby=lastLoginTime&category=user&Submit=搜索"> -->
<!--			<?php $sql="select count(*) as num from ".MEMBER." where status='1'";$db->query($sql);echo $db->fetchField('num');?> -->
<!-- 			</a> -->
<!-- 			</td> -->
<!--             <td><strong>待审核产品</strong></td> -->
<!--             <td> -->
<!-- 			<a href="module.php?type=0&statu=0&order=1&title=1&Submit=搜索&m=product&s=prolist.php"> -->
<!--			<?php $sql="select count(*) as num from ".PRO." where status='0'";$db->query($sql);echo $db->fetchField('num');?> -->
<!-- 			</a> -->
<!-- 			</td> -->
<!-- 		 </tr> -->
<!-- 		  <tr> -->
<!--             <td align="left"><strong>到期广告数</strong></td> -->
<!--             <td> -->
<!-- 			<a href="advs_con_list.php?endtime=1"> -->
<!--			<?php $time=time()-3600*24*7;$sql="select count(*) as num from ".ADVSCON." where etime<='$time'";$db->query($sql);echo $db->fetchField('num');?> -->
<!-- 			</a> -->
<!-- 			</td> -->
           
<!-- 		  </tr> -->
          
		   <?php
            $lip=getip();
			$nt=time();
		    $sql="update ".ADMIN." set logoip='$lip',lastlogotime='$nt' where user='".$_SESSION["ADMIN_USER"]."'";
            $db->query($sql);
		  ?>
		            <tr class="theader">
            <td height="20" colspan="4" align="left"><?php echo lang_show('myinfo');?></td>
          </tr>
          <tr>
            <td width="10%" align="left"><?php echo lang_show('yourgroup');?></td>
            <td width="40%"><?php echo $_SESSION["ADMIN_USER"];?></td>
            <td width="10%"><?php echo lang_show('lastlogoip');?></td>
            <td width="40%"><?php echo $re['logoip'];?></td>
          </tr>
          <?php 
		  $sql="select * from ".ADMIN." where user='".$_SESSION["ADMIN_USER"]."'";
		  $db->query($sql);
          $re=$db->fetchRow();
		  ?>
		   <tr>
            <td width="10%" align="left"><?php echo lang_show('logoip');?></td>
            <td><?php echo getip();?></td>
            <td><?php echo lang_show('todayis');?></td>
            <td><?php echo date("Y-m-d H:i:s", time());?></td>
	      </tr>
          <tr>
            <td align="left"><?php echo lang_show('lastlogotime');?></td>
            <td><?php echo date("Y-m-d H:i:s",$re['lastlogotime']);?></td>
            <td><?php echo lang_show('logonum');?></td>
            <td><?php echo $re['logonums'];?></td>
          </tr>
      </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="0"> 
          <tr class="theader">
            <td height="20" colspan="2" align="left">系统信息</td>
          </tr>
          <tr>
            <td height="10" align="left" valign="middle">服务器信息</td>
            <td height="10" align="left" valign="middle" ><?php echo $_SERVER['SERVER_SIGNATURE'];?></td>
          </tr>
          <tr>
            <td height="20" align="left" valign="middle" >数据库版本</td>
            <td height="20" align="left" valign="middle" ><?php echo mysql_get_server_info();?></td>
          </tr>
        </table>
	</div>
</div>
</body>
</html>